<?php

use think\migration\Migrator;

@set_time_limit(0);
@ini_set('memory_limit', -1);

/**
 * 新增日志数据库
 */
class InstallLog extends Migrator
{
    public function change()
    {
        $this->_create_system_queue_log();
    }

    /**
     * 创建数据对象
     * @class SystemQueueLog
     * @table system_queue_log
     * @return void
     */
    private function _create_system_queue_log()
    {
        // 当前数据表
        $table = 'system_queue_log';

        // 存在则跳过
        if ($this->hasTable($table)) return;

        // 创建数据表
        $this->table($table, [
            'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '辅种日志',
        ])
            ->addColumn('msg', 'string', ['limit' => 2048, 'default' => '', 'null' => true])
            ->create();

        // 修改主键长度
        $this->table($table)->changeColumn('id', 'integer', ['limit' => 11, 'identity' => true]);
    }
}
